<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class ProjectInvestorRecom_model extends CI_Model {

	public $tablename = 'hpg_project_investor_recom';
	
	public $tabinvestor = 'hpg_investor';

	public function __construct()
	{
		parent::__construct();
	}
	
	public function gePageList($project_id, $page=1, $limit=20){
	    if( !$project_id ){
	        return false;
	    }
	    $query = $this->db->where(['project_id'=>$project_id])->join($this->tabinvestor.' as a', $this->tablename.'.investor_id=a.id');
	    $start = ($page-1)*$limit;
	    $count = $query->count_all_results($this->tablename, false);
	    $list = $query->select('a.*,'.$this->tablename.'.status,next,addr,fb_status')->limit($limit, $start)->get_array();
	    return [intval($count), $list ? $list : []];
	}
	
	public function getByInvestorId($investor_id){
	    if( !$investor_id ){
	        return false;
	    }
	    $data = $this->db->from($this->tablename)->where('investor_id', $investor_id)->fetchOne();
	    return $data;
	}
}